<?php
namespace app\index\model;
use think\Model;
use think\model\concern\SoftDelete;

class Article extends Model
{
    protected $autoWriteTimestamp = 'datetime';//自动生成当前时间戳
    //文章主表和用户表
    public function user()
    {
        return $this->belongsTo('user','user_id','id');
    }

    //主表和附表关联
    public function articleDetail()
    {
      return  $this->hasOne('articleDetail','article_id','id');
    }
    //文章主表和关键字关联
    public function keyword()
    {
        return $this->hasOne('keyword','article_id','id');
    }

    //文章主表和栏目关联
    public function category()
    {
        return $this->hasOne('category','id','category_id');
    }

}